package com.tingyuge.base.thread.wang.chapter5;

import java.util.Optional;
import java.util.stream.IntStream;

public class ThreadJoin {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{

            IntStream.range(0,1000).forEach(i->{
                Optional.of(Thread.currentThread().getName()+"-->"+i ).ifPresent(System.out::println);
            });

        },"t1");
        Thread t2= new Thread(()->{


                IntStream.range(0,1000).forEach(i->{
                    Optional.of(Thread.currentThread().getName()+"-->"+i ).ifPresent(System.out::println);
                });


        },"t2");
        t1.start();
        t2.start();
        t1.join();

        t2.join();
        System.out.println("主线程......");
    }
}
